<template>
  <div>
    <el-form ref="form" size="small" :inline="true" label-width="60px">
      <el-form-item label="UUID">
        <el-input style="width: 400px" v-model="uuid"></el-input>
      </el-form-item>
      <el-form-item label="排序">
        <el-select class="header-item" size="small" v-model="indexSort" placeholder="索引排序">
          <el-option key="1" label="索引正序" value="1"></el-option>
          <el-option key="-1" label="索引反序" value="-1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="时间">
        <el-date-picker
          class="header-item"
          size="small"
          v-model="dateValues"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button @click="searchBtnClick">查询</el-button>
      </el-form-item>
      <el-table
        :data="dataArr"
        border
        style="width: 100%">
        <el-table-column label="数据">
          <template slot-scope="scope">
            {{ scope.row }}
          </template>
        </el-table-column>
      </el-table>
    </el-form>
  </div>
</template>

<script lang="ts">
  import { Vue, Component } from 'vue-property-decorator'
  import { get } from '@/api/ajax'
  import { GetDataApi } from '@/api/apis'
  import DataModel from "@/models/DataModel";
  import YBPopView from "@/utils/popView";

  @Component({
    components: {}
  })

  export default class Home extends Vue{

    uuid = ''
    total = 0
    indexSort = '1'
    dateValues: Array<Date> = []
    dataArr: Array<DataModel> = []

    searchBtnClick() {
      if (!this.uuid) {
        YBPopView.msgError('请输入UUID')
        return
      }
      const [ startTime, endTime ] = this.dateValues
      get(`${GetDataApi.getArrayData}/${this.uuid}`, {
        startTime: startTime ? startTime.getTime() : undefined,
        endTime: endTime ? endTime.getTime() : undefined,
        indexSort: this.indexSort,
      }).then((data: any) => {
        this.dataArr = data.list
        this.total = data.total
      })
    }
  }
</script>

<style scoped>

</style>
